39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
73#define DCMOTOR32_CONTROL_SDO_SEL_CONTROL 0x00
74#define DCMOTOR32_CONTROL_SDO_SEL_STATUS 0x80
75#define DCMOTOR32_CONTROL_SDO_SEL_MASK 0x80
76#define DCMOTOR32_CONTROL_MODE_PD_GND_OUT 0x00
77#define DCMOTOR32_CONTROL_MODE_PU_SHORT_TO_GND 0x08
78#define DCMOTOR32_CONTROL_MODE_SLOW_DECAY_LSB 0x10
79#define DCMOTOR32_CONTROL_MODE_SLOW_DECAY_LSA 0x18
80#define DCMOTOR32_CONTROL_MODE_FAST_DECAY_HSB 0x20
81#define DCMOTOR32_CONTROL_MODE_FAST_DECAY_HSB_OPEN_LOAD 0x28
82#define DCMOTOR32_CONTROL_MODE_FORWARD_HSB 0x30
83#define DCMOTOR32_CONTROL_MODE_FORWARD_LSA 0x38
84#define DCMOTOR32_CONTROL_MODE_FAST_DECAY_HSA_OPEN_LOAD 0x40
85#define DCMOTOR32_CONTROL_MODE_FAST_DECAY_HSA 0x48
86#define DCMOTOR32_CONTROL_MODE_REVERSE_LSB 0x50
87#define DCMOTOR32_CONTROL_MODE_REVERSE_HSA 0x58
88#define DCMOTOR32_CONTROL_MODE_SLOW_DECAY_HSB 0x60
89#define DCMOTOR32_CONTROL_MODE_SLOW_DECAY_HSA 0x68
90#define DCMOTOR32_CONTROL_MODE_HALF_BRIDGE_A_TRI_STATE 0x70
91#define DCMOTOR32_CONTROL_MODE_HALF_BRIDGE_B_TRI_STATE 0x78
92#define DCMOTOR32_CONTROL_MODE_MASK 0x78
93#define DCMOTOR32_CONTROL_CURRENT_SENSE_DISABLE 0x00
94#define DCMOTOR32_CONTROL_CURRENT_SENSE_ENABLE 0x04
95#define DCMOTOR32_CONTROL_CURRENT_SENSE_MASK 0x04
96#define DCMOTOR32_CONTROL_SLEW_RATE_SLOW 0x00
97#define DCMOTOR32_CONTROL_SLEW_RATE_FAST 0x02
98#define DCMOTOR32_CONTROL_SLEW_RATE_MASK 0x02
99#define DCMOTOR32_CONTROL_EN_DISABLE 0x00
100#define DCMOTOR32_CONTROL_EN_ENABLE 0x01
101#define DCMOTOR32_CONTROL_EN_MASK 0x01
107#define DCMOTOR32_STATUS_SDO_SEL_CONTROL 0x00
108#define DCMOTOR32_STATUS_SDO_SEL_STATUS 0x80
109#define DCMOTOR32_STATUS_SDO_SEL_MASK 0x80
110#define DCMOTOR32_STATUS_OCA_MASK 0x40
111#define DCMOTOR32_STATUS_OCB_MASK 0x20
112#define DCMOTOR32_STATUS_OL_MASK 0x10
113#define DCMOTOR32_STATUS_UV_MASK 0x08
114#define DCMOTOR32_STATUS_TSDA_MASK 0x04
115#define DCMOTOR32_STATUS_TSDB_MASK 0x02
116#define DCMOTOR32_STATUS_EN_MASK 0x01
122#define DCMOTOR32_R8 1000.0
123#define DCMOTOR32_R9 820.0
129#define DCMOTOR32_NUM_CONVERSIONS 200
135#define DCMOTOR32_VREF_3V3 3.3
136#define DCMOTOR32_VREF_5V 5.0
137#define DCMOTOR32_VREF_DEFAULT DCMOTOR32_VREF_3V3
143#define DCMOTOR32_TIMEOUT_MS 2000
161#define DCMOTOR32_MAP_MIKROBUS( cfg, mikrobus ) \
162 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
163 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
164 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
165 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
166 cfg.is_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
dcmotor32_return_value_t
DC Motor 32 Click return value data.
Definition dcmotor32.h:214
@ DCMOTOR32_ERROR
Definition dcmotor32.h:216
@ DCMOTOR32_OK
Definition dcmotor32.h:215
err_t dcmotor32_read_adc_raw(dcmotor32_t *ctx, uint16_t *data_out)
DC Motor 32 read raw IS ADC value function.
err_t dcmotor32_get_out_current(dcmotor32_t *ctx, float *current)
DC Motor 32 get output current function.
err_t dcmotor32_read_adc_volt_avg(dcmotor32_t *ctx, uint16_t num_conv, float *volt_avg)
DC Motor 32 read IS pin voltage level average function.
err_t dcmotor32_set_fast_slew_rate(dcmotor32_t *ctx)
DC Motor 32 set fast slew rate function.
err_t dcmotor32_disable_device(dcmotor32_t *ctx)
DC Motor 32 disable device function.
err_t dcmotor32_enable_isense(dcmotor32_t *ctx)
DC Motor 32 enable current sense function.
err_t dcmotor32_read_adc_volt(dcmotor32_t *ctx, float *data_out)
DC Motor 32 read IS pin voltage level function.
err_t dcmotor32_enable_device(dcmotor32_t *ctx)
DC Motor 32 enable device function.
void dcmotor32_cfg_setup(dcmotor32_cfg_t *cfg)
DC Motor 32 configuration object setup function.
err_t dcmotor32_set_slow_slew_rate(dcmotor32_t *ctx)
DC Motor 32 set slow slew rate function.
err_t dcmotor32_set_control(dcmotor32_t *ctx, uint8_t control)
DC Motor 32 set control function.
err_t dcmotor32_calib_offset(dcmotor32_t *ctx)
DC Motor 32 calibrate offset function.
err_t dcmotor32_disable_isense(dcmotor32_t *ctx)
DC Motor 32 disable current sense function.
err_t dcmotor32_init(dcmotor32_t *ctx, dcmotor32_cfg_t *cfg)
DC Motor 32 initialization function.
err_t dcmotor32_default_cfg(dcmotor32_t *ctx)
DC Motor 32 default configuration function.
err_t dcmotor32_set_operation_mode(dcmotor32_t *ctx, uint8_t mode)
DC Motor 32 set operation mode function.
err_t dcmotor32_set_adc_vref(dcmotor32_t *ctx, float vref)
DC Motor 32 set vref function.
err_t dcmotor32_get_status(dcmotor32_t *ctx)
DC Motor 32 get status function.
DC Motor 32 Click configuration object.
Definition dcmotor32.h:194
pin_name_t is_pin
Definition dcmotor32.h:202
analog_in_resolution_t resolution
Definition dcmotor32.h:204
float vref
Definition dcmotor32.h:205
pin_name_t sck
Definition dcmotor32.h:198
pin_name_t mosi
Definition dcmotor32.h:197
pin_name_t miso
Definition dcmotor32.h:196
pin_name_t cs
Definition dcmotor32.h:199
DC Motor 32 Click context object.
Definition dcmotor32.h:176
digital_out_t cs
Definition dcmotor32.h:179
digital_out_t sck
Definition dcmotor32.h:178
digital_out_t mosi
Definition dcmotor32.h:177
digital_in_t miso
Definition dcmotor32.h:180
float zero_curr_offset
Definition dcmotor32.h:185
uint8_t status
Definition dcmotor32.h:184
uint8_t control
Definition dcmotor32.h:183
analog_in_t adc
Definition dcmotor32.h:181